/**
 * Book Organizer
 */


// Create a books array containing three book objects
const books = [
  {
    title: 'To Kill a Mockingbird',
    authorName: 'Harper Lee',
    releaseYear: 1960
  },
  {
    title: '1984',
    authorName: 'George Orwell',
    releaseYear: 1949
  },
  {
    title: 'Pride and Prejudice',
    authorName: 'Jane Austen',
    releaseYear: 1813
  }
];

const sortByYear = (book1, book2) => {
  if (book1.releaseYear < book2.releaseYear) return -1;
  else if (book1.releaseYear === book2.releaseYear) return 0;
  else return 1;
}

const filteredBooks = books.filter(
  book => book.releaseYear > 1900,
)


filteredBooks.sort(sortByYear);

console.log(filteredBooks);
